//
//  WebViewController.m
//  MeterMart
//
//  Created by ENERGY on 2018/11/8.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "WebViewController.h"
#import "MessageViewController.h"
@interface WebViewController ()
@property (nonatomic, strong)UIWebView * webView;
@end

@implementation WebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.webView];
    //回退键
    UIButton * backBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30/WIDTH_6_SCALE, 30/WIDTH_6_SCALE)];
    [backBtn addTarget:self action:@selector(backBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [backBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    UIBarButtonItem * leftItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    
    NSUserDefaults*pushJudge = [NSUserDefaults standardUserDefaults];
    if([[pushJudge objectForKey:@"push"] isEqualToString:@"push"]) {
        [self.navigationController setNavigationBarHidden:NO animated:YES];
        self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@""] style:UIBarButtonItemStylePlain target:self action:@selector(rebackToRootViewAction)];
    }
}
- (UIWebView *)webView{
    if (!_webView) {
        _webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - BOTTOM_HEIGHT - NAVI_HEIGHT)];
    }return _webView;
}
- (void)backBtnClick{
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
- (void)leapViewController{
    NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]];
    [self.webView loadRequest:request];
}

- (void)rebackToRootViewAction{
    NSLog(@"");
}
@end
